<template>
<!-- 咨询 -->
<div class="">
    <div class="pr10">
        <div class="analyItem">
            <p class="analyItemTit tx-center">状态</p>
            <div class="analyItemCon">
            </div>
        </div>
    </div>
    <div class="thinScroll pr10" v-scrollHeight="84">
        <router-link tag="div" exact :to="{path:routerPath('threeAll'),query:{stageInfo: this.stageInfo,pmUserInfo: this.pmUserInfo, userInfoFn: this.userInfoFn}}" class="analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center" :class="((userInfoFn.u_name=== undefined || userInfoFn.u_name=== '' || userInfoFn.u_name=== null) ||
                    (stageInfo.education === undefined || stageInfo.education === '' || stageInfo.education === null) ||
                        (stageInfo.certificates === undefined || stageInfo.certificates === '' || stageInfo.certificates === null) ||
                        (userInfoFn.phone === undefined || userInfoFn.phone === '' || userInfoFn.phone === null) ||
                    (userInfoFn.weixin === undefined || userInfoFn.weixin === '' || userInfoFn.weixin === null) ||
                    (userInfoFn.sex=== undefined || userInfoFn.sex=== '' || userInfoFn.sex=== null) ||
                    (pmUserInfo.work_type=== undefined || pmUserInfo.work_type=== '' || pmUserInfo.work_type=== null) ||
                    (pmUserInfo.worker_year=== undefined || pmUserInfo.worker_year=== '' || pmUserInfo.worker_year=== null) ||
                    (pmUserInfo.worker_number=== undefined || pmUserInfo.worker_number === '' || pmUserInfo.worker_number === null)) ? '' : 'analyLightGreen'">基本资料</p >
            <div class="analyItemCon">
                <p class="col-md-6">姓名：<span class="cLightGray pr8">{{userInfoFn.u_name ? userInfoFn.u_name : ''}}</span></p >
                <p class="col-md-6">性别：<span class="cLightGray pr8">{{userInfoFn.sex ? userInfoFn.sex : ''}}</span></p >
                <p class="col-md-6">电话：<span class="cLightGray pr8">{{userInfoFn.phone ? userInfoFn.phone : ''}}</span></p >
                <p class="col-md-6">微信：<span class="cLightGray pr8">{{userInfoFn.weixin? userInfoFn.weixin : ''}}</span></p >
                <span v-if="(userInfoFn.u_name=== undefined || userInfoFn.u_name=== '' || userInfoFn.u_name=== null) ||
                    (stageInfo.education === undefined || stageInfo.education === '' || stageInfo.education === null) ||
                    (stageInfo.certificates === undefined || stageInfo.certificates === '' || stageInfo.certificates === null) ||
                    (userInfoFn.phone === undefined || userInfoFn.phone === '' || userInfoFn.phone === null) ||
                    (userInfoFn.weixin === undefined || userInfoFn.weixin === '' || userInfoFn.weixin === null) ||
                    (userInfoFn.sex=== undefined || userInfoFn.sex=== '' || userInfoFn.sex=== null) ||
                    (pmUserInfo.work_type=== undefined || pmUserInfo.work_type=== '' || pmUserInfo.work_type=== null) ||
                    (pmUserInfo.worker_year=== undefined || pmUserInfo.worker_year=== '' || pmUserInfo.worker_year=== null) ||
                    (pmUserInfo.worker_number=== undefined || pmUserInfo.worker_number === '' || pmUserInfo.worker_number === null)" class="circlemark circlemark-lightRed">待</span>
                    <span v-else class="circlemark circlemark-lightGreen">全</span>
                </div>
        </router-link>
        <router-link tag="div" exact :to="{path:routerPath('threeRegion'),query:{userInfoFn: userInfoFn}}" class="analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center" :class="((userInfoFn.u_sheng=== undefined || userInfoFn.u_sheng=== '' || userInfoFn.u_sheng=== null) ||
                (userInfoFn.u_shi=== undefined || userInfoFn.u_shi=== '' || userInfoFn.u_shi=== null) ||
                (userInfoFn.region_name=== undefined || userInfoFn.region_name === '' || userInfoFn.region_name === null)) ? '' : 'analyLightGreen'">地区</p >
            <div class="analyItemCon">
                <p class="col-md-6">地区：<span class="cLightGray pr8">{{userInfoFn.u_sheng ? userInfoFn.u_sheng : ''}}</span></p >
                <p class="col-md-6">分司：<span class="cLightGray pr8">{{userInfoFn.region_name ? userInfoFn.region_name : ''}}</span></p >
                <span v-if="(userInfoFn.u_sheng=== undefined || userInfoFn.u_sheng=== '' || userInfoFn.u_sheng=== null) ||
                (userInfoFn.region_name=== undefined || userInfoFn.region_name === '' || userInfoFn.region_name === null) ||
                (userInfoFn.u_shi=== undefined || userInfoFn.u_shi=== '' || userInfoFn.u_shi=== null)" class="circlemark circlemark-lightRed">待</span>
                <span v-else class="circlemark circlemark-lightGreen">全</span>
            </div>
        </router-link>
        <!-- <router-link tag="div" exact :to="{path:routerPath('threeStrength'),query:{pmUserInfo: pmUserInfo}}" class="analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center">实力</p>
            <div class="analyItemCon">
                <p class="col-md-6">行业经验：<span class="cLightGray pr8">{{pmUserInfo.worker_year ?pmUserInfo.worker_year: 0}}</span></p >
                <p class="col-md-6">固定工人：<span class="cLightGray pr8">{{pmUserInfo.worker_number ?pmUserInfo.worker_number: 0}}</span></p >
                                    <span v-if="(pmUserInfo.worker_year=== undefined || pmUserInfo.worker_year=== '' || pmUserInfo.worker_year=== null) ||
                    (pmUserInfo.worker_number=== undefined || pmUserInfo.worker_number === '' || pmUserInfo.worker_number === null)" class="circlemark circlemark-lightRed">待</span>
                    <span v-else class="circlemark circlemark-lightGreen">全</span>
                </div>
                </router-link> -->
        <router-link tag="div" exact :to="{path:routerPath('threeMessage'),query:{pressIndex: 3, stageInfo: this.stageInfo, userInfoFn: this.userInfoFn, sendMessageTime: this.sendMessageTime}}" class="analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center" :class="((this.stageInfo.activation_app === null || this.stageInfo.activation_app === '' || this.stageInfo.activation_app === undefined || this.stageInfo.activation_app === 1) ||
                (this.sendMessageTime === undefined || this.sendMessageTime === '' || this.sendMessageTime === null)
                ) ? '' : 'analyLightGreen'">时间</p >
            <div class="analyItemCon">
                <p class="col-md-6">录入时间：<span class="cLightGray pr8">{{ stageInfo.create_date ? stageInfo.create_date.substring(0,10) : ''}}</span></p >
                <p class="col-md-6">激活时间：<span class="cLightGray pr8">{{ this.sendMessageTime ? this.sendMessageTime.substring(0,10) : ''}}</span></p >
                <p class="fl">
                    <span v-if="(this.stageInfo.activation_app === null || this.stageInfo.activation_app === '' || this.stageInfo.activation_app === undefined || this.stageInfo.activation_app === 1) ||
                (this.sendMessageTime === undefined || this.sendMessageTime === '' || this.sendMessageTime === null) ||
                (this.leftInfo.rs_app_id=== undefined || this.leftInfo.rs_app_id=== '' || this.leftInfo.rs_app_id=== null)" class="circlemark circlemark-lightRed">待</span>
                    <span v-else class="circlemark circlemark-lightGreen">全</span>
                </p>
            </div>
        </router-link>
        <!-- <router-link tag="div" exact :to="{path:routerPath('threeMessage'),query:{pressIndex: 4, sendMessageTime: this.sendMessageTime}}" class="analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center" :class="((this.sendMessageTime === undefined || this.sendMessageTime === '' || this.sendMessageTime === null)) ? '' : 'analyLightGreen'">短信邀约</p >
            <div class="analyItemCon">
                <p class="col-md-6"><span class="cLightGray pr8 cRed">{{this.sendMessageTime ? this.sendMessageTime.substring(0,10) : ''}}</span></p >
                <p class="fl">
                    <span v-if="(this.sendMessageTime === undefined || this.sendMessageTime === '' || this.sendMessageTime === null)" class="circlemark circlemark-lightRed">待</span>
                    <span v-else class="circlemark circlemark-lightGreen">全</span>
                </p>
            </div>
        </router-link> -->
        <!-- <router-link tag="div" exact :to="{path:routerPath('threeAPP'),query:{pressIndex: 5, stageInfo: stageInfo}}" class="analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center" :class="((stageInfo.activation_app === undefined || stageInfo.activation_app === '' || stageInfo.activation_app === null)) ? '' : 'analyLightGreen'">APP</p >
            <div class="analyItemCon">
                <p class="col-md-6"><span class="cLightGray pr8">{{stageInfo.activation_app ? (stageInfo.activation_app==0?'激活':'未激活') : ''}}</span></p >
                <p class="fl">
                    <span v-if="(stageInfo.activation_app === undefined || stageInfo.activation_app === '' || stageInfo.activation_app === null)" class="circlemark circlemark-lightRed">待</span>
                    <span v-else class="circlemark circlemark-lightGreen">全</span>
                </p>
            </div>
        </router-link> -->
        <router-link tag="div" exact :to="{path:routerPath('threeStandardZi'),query:{pressIndex: 7, standards: this.standards}}" class="analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center"  :class="(Number(this.standards.length) === 0 || this.scores < (30 * this.pmStandardSize)) ? '' : 'analyLightGreen'">解答</p >
            <div class="analyItemCon">
                <p class="col-md-6">总分：<span class="cLightGray pr8">{{ 40 * this.pmStandardSize }}</span></p >
                <p class="col-md-6">得分：<span class="cLightGray pr8">{{ Number(this.standards.length) > 0 ? this.scores : 0 }}</span></p >
                <p class="fl">
                    <span v-if="Number(this.standards.length) === 0 || this.scores < (30 * this.pmStandardSize)" class="circlemark circlemark-lightRed">待</span>
                    <span v-else class="circlemark circlemark-lightGreen">过</span>
                </p>
            </div>
        </router-link>
        <router-link tag="div" exact :to="{path:routerPath('threeIntroduce'),query:{pressIndex: 4}}" class="analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center">介绍</p >
            <div class="analyItemCon">
                <p class="col-md-6">瑞祥介绍</p >
            </div>
        </router-link>

    </div>
    <!-- <div tag="div" exact :to="{path:routerPath('hander'),query:{pressIndex: 8}}" class="analyItem anItemBor" active-class="anItemBor-active"> -->
        <div class="analyItem" active-class="anItemBor-active">
        <p class="analyItemTit tx-center">处理</p >
      <div class="analyItemCon tx-center" v-if="Number(this.userInfo.areaId) === 39">
          <el-button @click="commit" v-if="(userInfoFn.u_name=== undefined || userInfoFn.u_name=== '' || userInfoFn.u_name=== null) ||
                    (userInfoFn.phone === undefined || userInfoFn.phone === '' || userInfoFn.phone === null) ||
                    (userInfoFn.weixin === undefined || userInfoFn.weixin === '' || userInfoFn.weixin === null) ||
                    (userInfoFn.sex=== undefined || userInfoFn.sex=== '' || userInfoFn.sex=== null) ||

                    (this.sendMessageTime === undefined || this.sendMessageTime === '' || this.sendMessageTime === null) ||
                    (stageInfo.activation_app === undefined || stageInfo.activation_app === '' || stageInfo.activation_app === null) ||
                    (userInfoFn.u_sheng=== undefined || userInfoFn.u_sheng=== '' || userInfoFn.u_sheng=== null) ||
                    (userInfoFn.region_name=== undefined || userInfoFn.region_name === '' || userInfoFn.region_name === null) ||
                    (userInfoFn.u_shi=== undefined || userInfoFn.u_shi=== '' || userInfoFn.u_shi=== null) ||

                    (pmuserInfo.work_type=== undefined || pmuserInfo.work_type=== '' || pmUserInfo.work_type=== null) ||
                    (pmUserInfo.worker_year=== undefined || pmUserInfo.worker_year=== '' || pmUserInfo.worker_year=== null) ||
                    (pmUserInfo.worker_number=== undefined || pmUserInfo.worker_number === '' || pmUserInfo.worker_number === null) ||
                    Number(this.standards.length) === 0 || this.scores < (30 * this.pmStandardSize)" disabled>通过</el-button>
        <el-button @click="commit" v-else>通过</el-button>
      </div>
      <div class="analyItemCon tx-center" v-else>
      </div>
     </div>
</div>
</template>
<script>
import { mapGetters, mapMutations } from 'vuex'
import { GetAppUserInfo, findStageInfoById, getPmStandardList, selectPmUserInfoManager, getSendMessageTime, getPmStandardUserList, nextStage } from '../Resources/Api'
export default {
    data () {
        return {
            pmStandardSize: 0,
            userInfoFn: {},
            stageInfo: {},
            pmStandards: [],
            pmUserInfo: {},
            standards: [], // 用户标准的集合
            scores: 0,
            // siName: '', // 分司名称
            siId: 0, // 分司id
            sendMessageTime: '' // 发送短信的时间
        }
    },
    created () {
        this.GetAppUserInfo()
        this.findStageInfoById()
        // this.getPmStandardList()
        this.selectPmUserInfoManager()
        this.getPmStandardUserList() // 查询用户标准成绩
        // this.shengChange()
        this.getSendMessageTime()
        // this.GetRegionList()
        this.getPmStandardList()
    },
    methods: {
        ...mapMutations({
            setUpdateLeft: `SET_UPDATE_LEFT`
        }),
        // 请求七师的接口
        GetAppUserInfo () {
            GetAppUserInfo({
                post: 4,
                appid: this.leftInfo.rs_app_id
            }).then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    this.userInfoFn = result.data.Body[0]
                }
            }).catch(err => {
                console.log('请求七师的接口失败，异常信息：' + err)
            })
        },
        getSendMessageTime () {
            getSendMessageTime({
                uid: this.leftInfo.uid
            }).then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    this.sendMessageTime = result.data.Body.sendMessageTime
                }
            }).catch(err => {
                console.log('获取发送短信的时间失败getSendMessageTime，异常信息：' + err)
            })
        },
        // 发送短信
        // SendInvitation () {
        //     SendInvitation({
        //         app_id: this.leftInfo.rs_app_id
        //     }).then(result => {
        //         if (Number(result.data.StatusCode) === 0) {
        //             layer.msg('发送成功')
        //             this.sendMessageTimeFn()
        //         }
        //     }).catch(err => {
        //         console.log('发送短信失败SendInvitation,异常信息：' + err)
        //     })
        // },
        // sendMessageTimeFn () {
        //     sendMessageTime({
        //         uid: this.leftInfo.uid
        //     }).then(result => {
        //         if (Number(result.data.StatusCode) === 0) {
        //             // leyer.msg('发送成功')
        //             this.$router.push(this.$route.matched[1].path)
        //         }
        //     }).catch(err => {
        //         console.log('保存发送短信时间失败sendMessageTime，异常信息：' + err)
        //     })
        // },
        // 获取市
        // shengChange () {
        //     let code = $('#projectSheng').find('option:selected').attr('data-code')
        //     GetAreaList({
        //         code: code
        //     }
        //     ).then(results => {
        //         if (results.status === 200) {
        //             const shiArry = results.data
        //             if (shiArry.length > 0) {
        //                 shiArry.forEach(shi => {
        //                     if (Number(shi.aid) === Number(this.stageInfo.city_value)) {
        //                         this.cityName = shi.name
        //                     }
        //                 })
        //             }
        //         }
        //     }).catch(error => { console.log(error) })
        // },
        // 查询所有的分司
        // GetRegionList () {
        //     GetRegionList().then(result => {
        //         if (Number(result.data.StatusCode) === 0) {
        //             this.regionList = result.data.Body
        //             this.regionList.forEach(region => {
        //                 if (region.regionId === this.leftInfo.areaId) {
        //                     this.siName = region.regionName
        //                     this.siId = region.regionId
        //                     return this.siName
        //                 }
        //             })
        //         }
        //     }).catch(err => {
        //         console.log('查询所有的分司失败GetRegionList，异常信息：' + err)
        //     })
        // },
        // 查询指定阶段的所有标准
        getPmStandardList () {
            getPmStandardList({
                stId: 1 // 认知阶段
            }).then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    this.pmStandardSize = result.data.Body.pmStandards.length
                }
            }).catch(err => {
                console.log('查询指定阶段的所有标准失败getPmStandardList，异常信息：' + err)
            })
        },
        // 查询用户成绩
        getPmStandardUserList () {
            getPmStandardUserList({
                stId: 1, // 阶段id 1-咨询，2-认知，3-考察，4-签约
                uid: this.leftInfo.uid
            }).then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    this.standards = result.data.Body.pmStandardUsers
                    // console.log(this.stageInfo)
                    if (this.standards.length > 0) {
                        this.standards.forEach(standard => {
                            const sdScore = Number(standard.sd_score)
                            if (sdScore === 1) {
                                this.scores += 40
                            } else if (sdScore === 2) {
                                this.scores += 30
                            } else if (sdScore === 3) {
                                this.scores += 20
                            } else if (sdScore === 4) {
                                this.scores += 10
                            }
                        })
                    }
                }
            }).catch(err => {
                console.log('查询用户成绩失败getPmStandardUserList，异常信息：' + err)
            })
        },
        // 获取所有信息
        findStageInfoById () {
            findStageInfoById({
                uid: this.leftInfo.uid /// this.leftInfo.uid // this.leftInfo.uid
            }).then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    this.stageInfo = result.data.Body
                }
            }).catch(err => {
                console.log(err)
            })
        },
        // // 根据阶段uid获取项目经理信息
        // getPmStandardList () {
        //     getPmStandardList({
        //         stId: this.leftInfo.stId
        //     }).then(result => {
        //         this.pmStandards = result.data.Body.pmStandards
        //     }).catch(err => {
        //         console.log(err)
        //     })
        // },
        // 根据阶段ID查询该阶段的所有标准
        selectPmUserInfoManager () {
            selectPmUserInfoManager({
                uid: this.leftInfo.uid// this.leftInfo.uid //this.leftInfo.uid //
            }).then(result => {
                this.pmUserInfo = result.data.Body
            }).catch(err => {
                console.log(err)
            })
        },
        // 点击通过
        commit () {
            nextStage({
                userId: this.leftInfo.uid
            }).then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    layer.msg('提交成功')
                    this.setUpdateLeft()
                }
            }).catch(err => {
                console.log('进入下一阶段失败nextStage,异常信息：' + err)
            })

            // this.$emit('listenToChildEvent', '认知')
        },
        // 路由跳转路径拼接
        routerPath (path) {
            return this.$route.matched[1].path + '/' + path
        },
        // 直接进行路由跳转路径
        routerPush (path) {
            this.$router.push(this.$route.matched[1].path + '/' + path)
        }

    },
    computed: {
        ...mapGetters(['leftInfo', 'updatePlate', 'userInfo'])
    },
    updated: function () {
    },
    watch: {
        updatePlate () {
            this.scores = 0
            this.getPmStandardUserList()
        },
        leftInfo () {
            this.scores = 0
            // if (this.leftInfo !== null && this.leftInfo !== undefined && this.leftInfo !== '') {
            this.findStageInfoById()
            this.GetAppUserInfo()
            // }
            this.getPmStandardUserList()
        },
        $route () {
            this.findStageInfoById()
            this.selectPmUserInfoManager()
            this.GetAppUserInfo()
        }
    }
}
</script>
